package ru.ncedu.java.vlku.hrs;

import ru.ncedu.java.vlku.hrs.dal.dao.DataBaseDAO;
import ru.ncedu.java.vlku.hrs.dal.dao.DataBaseFactory;
import ru.ncedu.java.vlku.hrs.model.Bill;
import ru.ncedu.java.vlku.hrs.model.CustomerAccount;
import ru.ncedu.java.vlku.hrs.model.Shop;
import ru.ncedu.java.vlku.hrs.uil.UserInterface;

import java.util.List;

public class Test {
    public static void main( String[] args ) {
        DataBaseDAO dao = DataBaseFactory.getInstance().getDataBaseDAO();

        CustomerAccount ca1 = dao.getCustomerAccountById(Long.valueOf(1)),
                ca2 = dao.getCustomerAccountById(Long.valueOf(2));
        Shop shop = dao.getShopById(Long.valueOf(1));
        List<CustomerAccount> cas = dao.getAllCustomerAccounts();
        for (int i = 0; i < cas.size(); i++) {
            System.out.println("Id = " + cas.get(i).getId() + ", Name: " + cas.get(i).getName() +
                    ", Email: " + cas.get(i).getEmail() + ", Phone: " + cas.get(i).getPhone());
        }

        System.out.println("Shop: id = " + shop.getId() + ", name: " + shop.getName() + ", address: " +
                shop.getAddress() + ", bills: ");

        //dao.createBill(new Bill(shop, ca2, new Date(System.currentTimeMillis())));
        Bill bill = dao.getBillById(Long.valueOf(1));

        System.out.println("bill id " + bill.getId() + ", customer account: " + bill.getCustomerAccount().getName());

        List<Bill> bills = dao.getAllBills();

        for (int i = 0; i < bills.size(); i++) {
            System.out.println("bill id " + bills.get(i).getId() +
                    ", customer account: " + bills.get(i).getCustomerAccount().getName());
        }
        UserInterface ui = new UserInterface();

        ui.run();
    }
}
